library(MASS)
#################################################
###Test for backward elimination of best model###
#################################################
#Subet NA data
s.dat <- na.omit(full.2003.2019[,c("confirm", "deforestation_shock2","log.nl","logged.pop","logged_state","logged_nonstate","p_anom","spei","t_anom","f_month2","f_month3","f_month4","f_month5","f_month6","f_month7","f_month8","f_month9","f_month10","f_month11","f_month12","c_gid","gid")])
#Run with the NA data
pois_glm_sep2 <- glm(confirm ~ deforestation_shock2+
                       log.nl + logged.pop +
                       logged_state + logged_nonstate +
                       p_anom+spei+t_anom+f_month2+f_month3+
                       f_month4+f_month5+f_month6+f_month7+f_month8+
                       f_month9 +f_month10+f_month11+
                       f_month12+c_gid, data=s.dat, family="poisson")
summary(pois_glm_sep2)

#Estimate step function
pois_glm_sep2.step <- step(pois_glm_sep2)
summary(pois_glm_sep2.step)
##Identify optimized model
